package com.dd.probe.web.controller;

import com.dd.probe.web.service.impl.ServerMetricsCollectServiceImpl;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author liuxianmeng
 * @CreateTime 2024/12/14 13:05
 * @Description 提供服务端指标信息
 */
@Slf4j
@RestController
@ApiModel("提供服务端指标信息")
@RequiredArgsConstructor
@RequestMapping("/metrics")
public class ServerMetricsCollectController {

    public final ServerMetricsCollectServiceImpl smcsi;

    @Deprecated
    @GetMapping("/server/hostInfo")
    @ApiOperation("获取服务器指标概况")
    public ResponseEntity hostInfo() {
        return ResponseEntity.ok().body(smcsi.hostInfo());
    }

    @Deprecated
    @GetMapping("/server/{serverIP}/status")
    @ApiOperation("【注意!此服务不应该在probe而在ops】获取服务器运行状态")
    public ResponseEntity serverStatus(@ApiParam("服务器IP")
                                @PathVariable String serverIP) {
        Boolean online = smcsi.isOnline(serverIP);
        return ResponseEntity.ok().body(online);
    }
}
